//
//  UINavigationControllerCustom.m
//  TestNav3
//
//  Created by pier on 12-5-28.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "UINavigationControllerCustom.h"
@implementation UINavigationControllerCustom

- (id)initWithRootViewController:(UIViewController *)rootViewController barBackgroundImage:(UIImage*)image
{
    self = [self initWithRootViewController:rootViewController];

#ifdef __IPHONE_5_0
    
    if (self)
    {
        if ([self.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
            [self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    }
    return self;
    
#endif
    
    UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
    imgView.frame = CGRectMake(0.0f, 0.0f, self.navigationBar.frame.size.width, self.navigationBar.frame.size.height);
    [self.navigationBar addSubview:imgView];
    [imgView release];
    return self;
}

@end
